<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>学生信息管理</title>
	<meta name="description" content="这是一个 index 页面">
	<meta name="keywords" content="index">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="renderer" content="webkit">
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="icon" type="image/png" href="${ctx}/assets/i/favicon.png">
	<link rel="apple-touch-icon-precomposed" href="${ctx}/assets/i/app-icon72x72@2x.png">
	<meta name="apple-mobile-web-app-title" content="Amaze UI" />
	<script src="${ctx}/assets/js/echarts.min.js"></script>
	<link rel="stylesheet" href="http://cdn.amazeui.org/amazeui/2.7.2/css/amazeui.min.css" />
	<script src="${ctx}/assets/js/echarts.min.js"></script>
	<script src="https://cdn.bootcss.com/jquery/2.2.3/jquery.js"></script>
	<link rel="stylesheet" href="${ctx}/assets/css/app.css">
</head>
	<body data-type="widgets">
		<script src="${ctx}/assets/js/theme.js"></script>
		<%@ include file="../../jspf/adminheader.jspf"%>
		<div class="am-g tpl-g" >
			<!-- 内容区域 -->
			<div class="row-content" style="margin-left:240px;">
				<div class="row-content am-cf">
					<div class="row">
						<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
							<div class="widget am-cf">
								<div class="widget-head am-cf">
									<div class="widget-title  am-cf">意向岗位管理</div>
								</div>
								<label for="dept" class="am-u-sm-1">部门 </label>
								<div class="am-u-sm-3">
									<select data-am-selected name="dept" id="dept"></select>
								</div>
								<label for="clazz" class="am-u-sm-1">班级	</label>
								<div class="am-u-sm-3">
									<select data-am-selected name="clazz" id="clazz"></select>
								</div>
								<div class="am-u-sm-1">
									<a class="am-btn am-icon-pencil" href="#" onclick="dataEcharts()">查询</a>
								</div>
							</div>
							<div id="main" class="am-u-sm-12 am-u-md-12 am-u-lg-12" style="height:500px;"></div>
						</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	
		<!-- 
		<script src="${ctx}/assets/js/amazeui.min.js"></script>
		 -->
		<script src="http://cdn.amazeui.org/amazeui/2.7.2/js/amazeui.min.js"></script>
		<script src="${ctx}/assets/js/app.js"></script>
		<script type="text/javascript">
			jQuery.download = function(url, data, method){
			    // 获得url和data
			    if( url && data ){ 
			        // data 是 string 或者 array/object
			        data = typeof data == 'string' ? data : jQuery.param(data);
			        // 把参数组装成 form的  input
			        var inputs = '';
			        jQuery.each(data.split('&'), function(){ 
			            var pair = this.split('=');
			            inputs+='<input type="hidden" name="'+ pair[0] +'" value="'+ pair[1] +'" />'; 
			        });
			        // request发送请求
			        jQuery('<form action="'+ url +'" method="'+ (method||'post') +'">'+inputs+'</form>')
			        .appendTo('body').submit().remove();
			    };
			};
			</script>
			<script type="text/javascript">
		//获取班级的ajax
		function getclazzes() {
			$.ajax({
				url : "${ctx}/std/getclazzes",
				type : "get",
				async : false,
				success : function(data) {
					$("#clazz").empty();
					$("#clazz").append('<option></option>');
					for ( var i in data) {
							$("#clazz").append("<option value='"+data[i].name+"'>"+data[i].name+"</option>");
					}
					$("#clazz").append('<option></option>');
				}
			});
		}
		function getdepts() {
			$.ajax({
				url : "${ctx}/std/getdepts",
				type : "get",
				async : false,
				success : function(data) {
					$("#dept").empty();	
					$("#dept").append('<option></option>');
					for ( var i in data) {
						$("#dept").append("<option value='"+data[i].name+"'>"+data[i].name+"</option>");
					}
				}
			});
		}
		getclazzes();
		getdepts();
	</script>
	<script type="text/javascript">
		function dataEcharts(){
			
			var myChart = echarts.init(document.getElementById('main'));
			
			 myChart.setOption( {
		            title: {
		            		x:'center',
		                	text: '岗位统计'
		            },
	            tooltip: {},
	            calculable: true,
	            xAxis: {
	                data: []
	            },
	            yAxis: {
	                type: 'value',
	                show: false
	            },
	            series: 
	            	[{
	                name: '岗位意向',
	                type: 'bar',
	                itemStyle: {
	                    normal: {
	                        color: function(params) {
	                            // build a color map as your need.
	                            var colorList = [
	                              '#B5C334','#FCCE10','#E87C25','#27727B',
	                               '#FE8463','#9BCA63','#FAD860','#F3A43B','#60C0DD',
	                               '#D7504B','#C6E579','#F4E001','#F0805A','#26C0C0','#C1232B'
	                            ];
	                            return colorList[params.dataIndex]
	                        },
	                        label: {
	                            show: true,
	                            position: 'top',
	                            formatter: '{b}\n{c}'
	                        }
	                    }
	                },
	                data: []
	            }]
	        });
				var clazz=$('#clazz').val();
				console.log(clazz);
				var dept =$('#dept').val()
	        $.ajax({
				url : "${ctx}/wechat/favjob/getdataecharts",
				data : {
					clazz:clazz,
					dept:dept
				},
				type : "post",
				async : false,
				success : function(data) {
					// 填入数据
				    var title = data.title + '岗位统计';
				    myChart.setOption({
				    	title: {
		                text: title
		           		 },
				        xAxis: {
				            data: data.category
				        },
				        series: [{
				            // 根据名字对应到相应的系列
				            name: '销量',
				            data: data.data
				        }]
				    });
				}
			});
	        // 使用刚指定的配置项和数据显示图表。
		}
	    </script>
	</body>

</html>